﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class area_admin_equipamentos : System.Web.UI.Page
{
    private EQUIPAMENTO equipamentos = new EQUIPAMENTO();
    private dbSisInfoDataContext Banco = new dbSisInfoDataContext();

    protected void Page_Load(object sender, EventArgs e)
    {
        Session["Titulo"] = "Equipamentos";

       /* linqEquipamentos.Where = "Nome.Contains(\"" + txtDescricao.Text + "\")";
        linqEquipamentos.DataBind();
        grdEquipamentos.DataBind();*/
    }

    protected void btnIncluir_Click(object sender, EventArgs e)
    {
        equipamentos.Nome = txtDescricao.Text;

        Banco.EQUIPAMENTOs.InsertOnSubmit(equipamentos);
        Banco.SubmitChanges();
        grdEquipamentos.DataBind();
         
        txtDescricao.Text = string.Empty;
    }
    protected void grdSituacoes_SelectedIndexChanged(object sender, EventArgs e)
    {
       
        Button1_ModalPopupExtender.Show();
       
    }
    protected void btnPesquisar_Click(object sender, EventArgs e)
    {
        linqEquipamentos.Where = "Nome.Contains(\""+txtDescricao.Text+"\")";
        linqEquipamentos.DataBind();
        grdEquipamentos.DataBind();

    }
  
    protected void grdEquipamentos_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
       
    }
    protected void btnSim0_Click(object sender, EventArgs e)
    {
        grdEquipamentos.DeleteRow(grdEquipamentos.SelectedIndex);
        grdEquipamentos.DataBind();
    }
    protected void grdEquipamentos_DataBound(object sender, EventArgs e)
    {
        if (grdEquipamentos.Rows.Count > 0)
        {
            grdEquipamentos.HeaderRow.Cells[0].Text += " - Quantidade de items: " + grdEquipamentos.Rows.Count.ToString();
        }
    }
    protected void grdEquipamentos_RowEditing(object sender, GridViewEditEventArgs e)
    {

    }
    protected void grdEquipamentos_RowCreated(object sender, GridViewRowEventArgs e)
    {
        string onmouseoverStyle = "this.style.backgroundColor='#FFFFCC';";
       // string onmouseoverStyle = "this.style.boder='solid 1 px red'";


        string onmouseoutStyle = "this.style.backgroundColor='@BackColor'";

        string rowBackColor = "transparent"; //String.Empty;

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", onmouseoverStyle);

            e.Row.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor));

        } 
    }
}
